﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataProcessRouteItem" @search="()=>{getTableDataProcessRouteItem();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="RoutieId_FormItem" prop="RoutieId" :label="$t('message.autotrans._Model_ProcessRouteItem_Routie')">
            <el-select v-model="searchDataProcessRouteItem.RoutieId" clearable>
               <el-option v-for="item in stateProcessRouteItem.AllRouties" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="GroupCode_FormItem" prop="GroupCode" :label="$t('message.autotrans._Model_ProcessRouteItem_GroupCode')">
            <el-input v-model="searchDataProcessRouteItem.GroupCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpCode_FormItem" prop="OpCode" :label="$t('message.autotrans._Model_ProcessRouteItem_OpCode')">
            <el-input v-model="searchDataProcessRouteItem.OpCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpName_FormItem" prop="OpName" :label="$t('message.autotrans._Model_ProcessRouteItem_OpName')">
            <el-input v-model="searchDataProcessRouteItem.OpName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpType_FormItem" prop="OpType" :label="$t('message.autotrans._Model_ProcessRouteItem_OpType')">
            <el-select v-model="searchDataProcessRouteItem.OpType" clearable>
               <el-option key="Assembling" value="Assembling" :label="$t('message.autotrans._Enum_OpTypeEnum_Assembling')"></el-option>
               <el-option key="Detection" value="Detection" :label="$t('message.autotrans._Enum_OpTypeEnum_Detection')"></el-option>
               <el-option key="Rework" value="Rework" :label="$t('message.autotrans._Enum_OpTypeEnum_Rework')"></el-option>
               <el-option key="TakePartInOrOut" value="TakePartInOrOut" :label="$t('message.autotrans._Enum_OpTypeEnum_TakePartInOrOut')"></el-option>
               <el-option key="Weild" value="Weild" :label="$t('message.autotrans._Enum_OpTypeEnum_Weild')"></el-option>
               <el-option key="PrintMark" value="PrintMark" :label="$t('message.autotrans._Enum_OpTypeEnum_PrintMark')"></el-option>
               <el-option key="Fds" value="Fds" :label="$t('message.autotrans._Enum_OpTypeEnum_Fds')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ErpOpCode_FormItem" prop="ErpOpCode" :label="$t('message.autotrans._Model_ProcessRouteItem_ErpOpCode')">
            <el-input v-model="searchDataProcessRouteItem.ErpOpCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="StdOpDuration_FormItem" prop="StdOpDuration" :label="$t('message.autotrans._Model_ProcessRouteItem_StdOpDuration')">
            <el-input v-model="searchDataProcessRouteItem.StdOpDuration" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="StdPrepDuration_FormItem" prop="StdPrepDuration" :label="$t('message.autotrans._Model_ProcessRouteItem_StdPrepDuration')">
            <el-input v-model="searchDataProcessRouteItem.StdPrepDuration" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="PolicyCheckPrevProc_FormItem" prop="PolicyCheckPrevProc" :label="$t('message.autotrans._Model_ProcessRouteItem_PolicyCheckPrevProc')">
            <el-select v-model="searchDataProcessRouteItem.PolicyCheckPrevProc" clearable>
               <el-option key="None" value="None" :label="$t('message.autotrans._Enum_PolicyCheckPrevProcEnum_None')"></el-option>
               <el-option key="Worked" value="Worked" :label="$t('message.autotrans._Enum_PolicyCheckPrevProcEnum_Worked')"></el-option>
               <el-option key="WorkedAndOK" value="WorkedAndOK" :label="$t('message.autotrans._Enum_PolicyCheckPrevProcEnum_WorkedAndOK')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="PolicyCheckProcBom_FormItem" prop="PolicyCheckProcBom" :label="$t('message.autotrans._Model_ProcessRouteItem_PolicyCheckProcBom')">
            <el-select v-model="searchDataProcessRouteItem.PolicyCheckProcBom" clearable>
               <el-option key="None" value="None" :label="$t('message.autotrans._Enum_PolicyCheckProcBomEnum_None')"></el-option>
               <el-option key="Over" value="Over" :label="$t('message.autotrans._Enum_PolicyCheckProcBomEnum_Over')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="PolicyCheckProcess_FormItem" prop="PolicyCheckProcess" :label="$t('message.autotrans._Model_ProcessRouteItem_PolicyCheckProcess')">
            <el-select v-model="searchDataProcessRouteItem.PolicyCheckProcess" clearable>
               <el-option key="AllowedEntryRepeat" value="AllowedEntryRepeat" :label="$t('message.autotrans._Enum_PolicyCheckProcessEnum_AllowedEntryRepeat')"></el-option>
               <el-option key="CheckBOMSource" value="CheckBOMSource" :label="$t('message.autotrans._Enum_PolicyCheckProcessEnum_CheckBOMSource')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CtlAttr_FormItem" prop="CtlAttr" :label="$t('message.autotrans._Model_ProcessRouteItem_CtlAttr')">
            <el-select v-model="searchDataProcessRouteItem.CtlAttr" clearable>
               <el-option key="Must" value="Must" :label="$t('message.autotrans._Enum_ProcCtlAttrEnum_Must')"></el-option>
               <el-option key="Optional" value="Optional" :label="$t('message.autotrans._Enum_ProcCtlAttrEnum_Optional')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Pos_FormItem" prop="Pos" :label="$t('message.autotrans._Model_ProcessRouteItem_Pos')">
            <el-input v-model="searchDataProcessRouteItem.Pos" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Etag_FormItem" prop="Etag" :label="$t('message.autotrans._Model_ProcessRouteItem_Etag')">
            <el-input v-model="searchDataProcessRouteItem.Etag" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Active_FormItem" prop="Active" :label="$t('message.autotrans._Model_ProcessRouteItem_Active')">
            <el-select v-model="searchDataProcessRouteItem.Active" clearable>
               <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
               <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipmentId_FormItem" prop="EquipmentId" :label="$t('message.autotrans._Model_ProcessRouteItem_EquipmentId')">
            <el-input v-model="searchDataProcessRouteItem.EquipmentId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipmentCode_FormItem" prop="EquipmentCode" :label="$t('message.autotrans._Model_ProcessRouteItem_EquipmentCode')">
            <el-input v-model="searchDataProcessRouteItem.EquipmentCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Aux_1_FormItem" prop="Aux_1" :label="$t('message.autotrans._Model_ProcessRouteItem_Aux_1')">
            <el-input v-model="searchDataProcessRouteItem.Aux_1" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Aux_2_FormItem" prop="Aux_2" :label="$t('message.autotrans._Model_ProcessRouteItem_Aux_2')">
            <el-input v-model="searchDataProcessRouteItem.Aux_2" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_ProcessRouteItem_CreateTime')">
            <el-date-picker v-model="searchDataProcessRouteItem.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_ProcessRouteItem_UpdateTime')">
            <el-date-picker v-model="searchDataProcessRouteItem.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_ProcessRouteItem_CreateBy')">
            <el-input v-model="searchDataProcessRouteItem.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_ProcessRouteItem_UpdateBy')">
            <el-input v-model="searchDataProcessRouteItem.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/ProcessManagement/ProcessRouteItem/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/ProcessManagement/ProcessRouteItem/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/ProcessManagement/ProcessRouteItem/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/ProcessManagement/ProcessRouteItem/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/ProcessManagement/ProcessRouteItem/ProcessRouteItemExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefProcessRouteItem" v-bind="tableDataProcessRouteItem">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/ProcessManagement/ProcessRouteItem/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ProcessManagement/ProcessRouteItem/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ProcessManagement/ProcessRouteItem/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageProcessManagementProcessRouteItemIndex;true;Digitalmes.ProcessManagement.Controllers;ProcessRouteItem">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { processrouteitemApi } from '/@/api/processmanagement/processrouteitem';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateProcessRouteItem = reactive({
    
    AllRouties: [] as any[],
});

const searchDataProcessRouteItem = ref({
        RoutieId: null,
        GroupCode: '',
        OpCode: '',
        OpName: '',
        OpType: undefined,
        ErpOpCode: '',
        StdOpDuration: null,
        StdPrepDuration: null,
        PolicyCheckPrevProc: undefined,
        PolicyCheckProcBom: undefined,
        PolicyCheckProcess: undefined,
        CtlAttr: undefined,
        Pos: null,
        Etag: '',
        Active: undefined,
        EquipmentId: null,
        EquipmentCode: '',
        Aux_1: '',
        Aux_2: '',
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefProcessRouteItem = ref();
const tableDataProcessRouteItem = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page工艺路线'),key: 'ProcessRouteItem_Routie',type: 'text',isCheck: true,colWidth:150},
      {title:ci.proxy.$t('message.autotrans.Page工序组'),key: 'ProcessRouteItem_GroupCode',type: 'text',isCheck: true},
	   	{title:ci.proxy.$t('message.autotrans.Page关联设备'),key: 'ProcessRouteItem_EquipmentCode',type: 'text',isCheck: true},
		// {title:ci.proxy.$t('message.autotrans.Page设备编号'),key: 'ProcessRouteItem_EquipmentCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工序编号'),key: 'ProcessRouteItem_OpCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工序名称'),key: 'ProcessRouteItem_OpName',type: 'text',isCheck: true,colWidth:150},
      {title:ci.proxy.$t('message.autotrans.Page工序类型'),key: 'ProcessRouteItem_OpType',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工厂工序'),key: 'ProcessRouteItem_ErpOpCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page标准加工工时'),key: 'ProcessRouteItem_StdOpDuration',type: 'text',isCheck: true,colWidth:120},
      {title:ci.proxy.$t('message.autotrans.Page标准准备工时'),key: 'ProcessRouteItem_StdPrepDuration',type: 'text',isCheck: true,colWidth:120},
      {title:ci.proxy.$t('message.autotrans.Page校验上一工序动作'),key: 'ProcessRouteItem_PolicyCheckPrevProc',type: 'text',isCheck: true,colWidth:120},
      {title:ci.proxy.$t('message.autotrans.Page校验生产BOM动作'),key: 'ProcessRouteItem_PolicyCheckProcBom',type: 'text',isCheck: true,colWidth:120},
      {title:ci.proxy.$t('message.autotrans.Page工艺校验策略'),key: 'ProcessRouteItem_PolicyCheckProcess',type: 'text',isCheck: true,colWidth:120},
      {title:ci.proxy.$t('message.autotrans.Page工艺管控属性'),key: 'ProcessRouteItem_CtlAttr',type: 'text',isCheck: true,colWidth:120},
      {title:ci.proxy.$t('message.autotrans.Page工艺位置'),key: 'ProcessRouteItem_Pos',type: 'text',sortable: 'custom',colWidth: 180,isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page处理标记'),key: 'ProcessRouteItem_Etag',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page激活'),key: 'ProcessRouteItem_Active',type: 'switch',isCheck: true},

      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'ProcessRouteItem_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'ProcessRouteItem_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'ProcessRouteItem_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'ProcessRouteItem_UpdateBy',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataProcessRouteItem = () => {
    tableRefProcessRouteItem.value.doSearch(processrouteitemApi().search, searchDataProcessRouteItem.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataProcessRouteItem)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataProcessRouteItem)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataProcessRouteItem)
};

// 删除
const onDelete = (row: any) => {
    processrouteitemApi().delete([row.ID]).then(() => { getTableDataProcessRouteItem()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefProcessRouteItem.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      processrouteitemApi().delete(selectedids).then(() => { getTableDataProcessRouteItem()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefProcessRouteItem.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataProcessRouteItem)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataProcessRouteItem)
};

const onExport = () => {
	const selected = tableRefProcessRouteItem.value.getSelectedRows();
	if (selected.length > 0) {
		processrouteitemApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		processrouteitemApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/ProcessManagement/ProcessRouteItem/GetProcessRoutes',[],false).then(x=>{stateProcessRouteItem.AllRouties = x});
        getTableDataProcessRouteItem();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

